/*************************************************************************
	> File Name: oj-538_linkmatrix_travial.cpp
	> Author: Wang Bo
	> Mail: 1276106221@qq.com
	> Created Time: 2020年11月20日 星期五 19时20分21秒
 ************************************************************************/

#include <iostream>
using namespace std;

int n, arr[25][25], check[25];

void func(int now) {
    if (now != 1) {
        cout << "-";
    }
    cout << now;
    check[now] = 1;
    for(int i = 1; i <= n; ++i) {
        if (check[i] == 0 && arr[now][i] == 1) {
            func(i);
        }
    }
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            cin >> arr[i][j];
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (check[i] == 0) {
            func(i);
        }
    }
    cout << endl;
    return 0;
}
